package cz.artin.gemini.shared.domain.admin;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinTable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import cz.artin.gemini.shared.domain.DomainObject;

@Entity
@Table(name = "adm_user")
@SequenceGenerator(name = DomainObject.SEQ_GENERATOR_NAME, sequenceName = "adm_user_seq", allocationSize = 1, initialValue = 1000)
public class User extends DomainObject {
	private static final long serialVersionUID = 3647982141174089963L;

	@Column(name = "user_id", unique = true, nullable = false, length = 50)
	private String userId;
	
	@Column(name = "user_name", unique = true, nullable = false, length = 50)
	private String userName;
	
	@Column(name = "password")
	private String password;
	
	@Column(name = "email")
	private String email;
	
	@Column(name = "company")
	private String company;
	
	//TODO status
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "adm_user_role",
			joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) },
			inverseJoinColumns = { @JoinColumn(name = "role_id", nullable = false, updatable = false) })
	private List<Role> roles = new ArrayList<>(0);

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}
	
	
}
